<!-- Student_TempFreeCourseChapterList.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>自由课程章节列表</title>
		<!-- <link rel="stylesheet" type="text/css" href="../../css/api.css" /> -->
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css" />
		<!-- <link rel="stylesheet" href="../../css/base.css"/> -->
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style type="text/css" media="screen">
			.noSign {
				width: auto;
			}
			.loadFailure {
				width: auto;
			}
			.chapter_cell_left_icon {
				height: 26px;
				margin-right: 10px;
				/*display:block;*/
			}
			.weui_cell_hd{
				height: 26px;
			}
			.weui_cell{
				padding: 15px;
			}
			.mui-table-view-cell.mui-collapse .mui-collapse-content{
				padding: 0px;
			}
			.weui_cell:before {
				left: 0px;
			}
			.big_chapter_div {
				margin-top: 10px;
			}
			.weui_panel {
				margin-top: 0;
			}
			.weui_cell {
				/*background-color: white;*/
			}
			.fen_ge_xian {
				height: 10px;
			}
			.chapter_title {
				margin-left: 4px;
			}
			.base_style_text_color .chapter_title{
				color: #18b4ed;
			}
			.base_content_font {
				font-size: 16px;
			}
			.base_tag_font {
				font-size: 14px;
			}
			.base_title_color_font {
				background-color: #f9f9f9;
			}
			.base_content_color_font {
				/*background-color: #FFFFFF;*/
			}
			.img_margin_left_1 {
				margin-left: 16px;
			}
			.img_margin_left_2 {
				margin-left: 32px;
			}
			.img_margin_left_3 {
				margin-left: 48px;
			}
			.img_margin_left_4 {
				margin-left: 64px;
			}
			.footer-view {
				position: fixed;
				left: 0;
				bottom: 0;
				margin: 0;
				width: 100%;
				height: 50px;
				padding: 0;
			}
			.footer-view .mui-btn-block {
				width: 100%;
				height: 100%;
				margin: 0;
				padding: 0;
				background-color: #ff9900;
				border-color: #ff9900;
				color: white;
				font-size: 16px;
			}
			.footer-view .mui-btn-block:active {
				background-color: #ff9900;
			}
			.mui-btn, button {
				border-radius: 0px;
				border-top-left-radius: 0px;
				border-top-right-radius: 0px;
				border-bottom-right-radius: 0px;
				border-bottom-left-radius: 0px;
			}
			.blank-div {
				height: 50px;
			}
			.mui-card {
			    box-shadow: 0px 0px 10px rgba(0,0,0,.1);
			}
			.section-chart{
				width: 80px;
				height: 80px;
			}
			.section-right-div{
				padding: 10px 20px 10px 20px; 
				/*height: 60px;*/
				float: right;
				width:-webkit-calc(100% - 80px); 
				width:-moz-calc(100% - 80px); 
				width:calc(100% - 80px); 
			}
			.section-title{
				display: -webkit-box;
				-webkit-box-orient: vertical;
				/*-webkit-line-clamp: 2;*/
				overflow: hidden;
				word-wrap: break-word;
			    white-space: normal; 
			}
			.cell-right-img{
				width: 20px;
			}
			.zhan-wei-div{
				height: 0;
			}
			.bottom-tiao{
				height: 20px;
			}
			.section-chart-mask{
				position: absolute;
				width: 80px;
				height: 80px;
				left: 10px;
				top: 10px;
			}
			.chapter-bg-content{
				background-color: #f0f0f0;
			}
			.base-content .mui-content>.mui-card:first-child{
				margin-top: 10px;
			}
			.base-content .mui-card{
				margin: 10px;
				border-color: #d5d5d5;
				border-radius: 0px;
				border-width: 0px;
			}
			.mui-card .mui-table-view .mui-table-view-cell:first-child, .mui-card .mui-table-view .mui-table-view-divider:first-child{
				border-top-left-radius: 0px;
			    border-top-right-radius: 0px; 
			}
			.mui-navigate-right{
				background-color: white;
			}
			.mui-navigate-right:active{
				background-color: white;
			}
			.cell-right-down{
				margin-left: 10px;
			}
			.folder-content{
				background-color: #f9f9f9;
			}
			.drop-down-tap-div{
				position: absolute;
				right: 0;
				top: 0;
				height: 100%;
				width: 70px;
			}
			.sub-chapter-content-fdiv{
				padding: 0 1px;
			}
			.sub-chapter-content{
				border: 7px solid #ededed;
			}
			.sub-chapter-content-line{
				/*height: 1px;
				width: 100%;
				border-top: 1px solid #dedede;
				-webkit-transform: scaleY(.5);
			    transform: scaleY(.5);*/
			    height: 10px;
			    width: 100%;
			    background-size: 100% 100%;
			    background-image: url(../../image/chapter_background.png);
			}
			.sub-chapter-content-hide{
				display:none;
			}
			/*.weui_cell:before {
			    left: 0;
			    border-top: 1px solid #fff;
			    color: #fff;
			    -webkit-transform: scaleY(.5);
			    transform: scaleY(.5);
			}*/
			.section-slider-handle{
				background-color: rgba(0,0,0,0);
				padding: 10px;
			}
			.section-content{
				display: none;
			}
			.section-cell{
				padding: 0;
			}
			.section-right-img{
				position: absolute;
				width: 20px;
				height: 20px;
				right: 16px;
				top: 37px;
			}
		</style>
		<link rel="stylesheet" type="text/css" href="../../css/chapterListBewrite.css">
	</head>
	<body>
		<div class="noSign noDataDiv" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure noInternetDiv" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button" class="mui-btn mui-btn-outlined" onclick="loadChapterData()">
				重新加载
			</button>
		</div>
		<div class="base-content bgcolor">
			<div id="free_chapter_content">
				<!--  -->
				<!-- <div class="mui-content chapter-bg-content">
					<div class="mui-card">
						<ul class="mui-table-view">
							<li class="mui-table-view-cell section-cell">
								<div class="section-slider-handle">
									<div class="section-right-div">
      									<p class="section-title base_dark_grey base_content_font">
											入库课程介绍
										</p>
      								</div>
      								<div id="chart" class="section-chart" style="background-color: red"></div>
      								<div class="section-chart-mask" style="background-color: yellow;"></div>
      								<img class="section-right-img" src="../../image/icon_bewrite_down.png">
								</div>
								<div class="section-content">
									<div class="weui_cell">
										<div class="weui_cell_hd">
											<img src="../../image/icon_taolun.png" alt="" class="chapter_cell_left_icon">
										</div>
										<div class="weui_cell_bd weui_cell_primary">
											<p class="base_dark_grey base_tag_font">
												<span>测验入库互动资源</span>
											</p>
										</div>
										<div class="weui-cell__ft">
											<img class="cell-right-img" src="../../image/icon_studied.png">
										</div>
									</div>
									<div class="bewrite-cell weui_cell">
										<div class="bewrite-div bewrite-div-min">
											<div class="bewrite-content">
												<p>
													奥斯卡到附近；拉斯科大姐夫；老师端分类考试的菲尼克斯带你飞；会计师带你飞会计师带你飞；可是当年发生的可能发；等级考试能否健康是电脑福利看你是否结束多年浪费空间你死定了
													奥斯卡到附近；拉斯科大姐夫；老师端分类考试的菲尼克斯带你飞；会计师带你飞会计师带你飞；可是当年发生的可能发；等级考试能否健康是电脑福利看你是否结束多年浪费空间你死定了
												</p>
												<img src="../../image/icon_nodata.png" width="100px;">
											</div>
											<div class="bewrite-bottom-hide" hidden="hidden">
												<span class="bewrite-bottom-span">
													收起
													<img class="icon-bewrite" src="../../image/icon_bewrite_up.png">
												</span>
											</div>
											<div class="bewrite-bottom-show">
												<span class="bewrite-bottom-span">
													展开更多
													<img class="icon-bewrite" src="../../image/icon_bewrite_down.png">
												</span>
											</div>
										</div>
									</div>
									<div id="" class="weui_cell sub_chapter_cell base_content_color_font">
										<div class="weui_cell_hd">
											<img src="../../image/010.png" alt="" class="chapter_cell_left_icon">
										</div>
										<div class="weui_cell_bd weui_cell_primary">
											<p class="base_dark_grey base_tag_font">
												<span class="chapter_title">去年买表</span>
											</p>
										</div>
										<div id="" class="weui-cell__ft">
											<img class="cell-right-img" src="../../image/icon_studied.png">
										</div>
										<div id="" class="weui-cell__ft cell-right-down">
											<img class="cell-right-img" src="../../image/icon_bewrite_down.png">
										</div>
										<div class="drop-down-tap-div"></div>
									</div>
									<div class="sub-chapter-content-line"></div>
									<div class="sub-chapter-content">
										<div class="weui_cell base_content_color_font">
											<div class="weui_cell_hd">
												<img src="../../image/icon_chapter_pdf.png" alt="" class="chapter_cell_left_icon">
											</div>
											<div class="weui_cell_bd weui_cell_primary">
												<p class="base_dark_grey base_tag_font">
													<span class="chapter_title">去年买表</span>
												</p>
											</div>
										</div>
										<div class="weui_cell base_content_color_font">
											<div class="weui_cell_hd">
												<img src="../../image/icon_chapter_pdf.png" alt="" class="chapter_cell_left_icon">
											</div>
											<div class="weui_cell_bd weui_cell_primary">
												<p class="base_dark_grey base_tag_font">
													<span class="chapter_title">去年买表</span>
												</p>
											</div>
										</div>
									</div>
								</div>
							</li>
						</ul>
					</div>
				</div> -->
				<!--  -->
			</div>
			<div class="bottom-tiao"></div>
		</div>
		<div class="blank-div" hidden="hidden"></div>
		<div class="footer-view" hidden="hidden">
			<button id="study_btn" type="button" onclick="onExamClick()" class="mui-btn mui-btn-block"></button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/echarts.min.js"></script>
	<script type="text/javascript" src="../../script/mui.min.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/getToken.js"></script>
	<script type="text/javascript" src="../../script/push.js"></script>
	<script type="text/javascript" src="../../script/setupBewrite.js"></script>
	<script type="text/javascript" src="../../script/attachmentManager.js"></script>
	<script type="text/javascript" src="../../script/chapterFolder.js"></script>
	<script type="text/javascript">
		var chapterArr = new Array();
		var subChapterObjc = new Object();
		var type = 0;
		//判断是否是要重新加载 基数加载  偶数不加载
		var testNum = '';
		//测验章节考试次数
		var firstLoad = true;
		var open_type = '';
		//判断当前课程考核的状态
		var score_id = '';
		var score = '';
		var currentVid = null;
		var freeCourseStart = null;
		apiready = function() {
		    sendBuriedNotifi(0, '自由课程章节列表', '028','');
			ReceNotifi();
			loadChapterData();
			setRefreshHeader();
			// startChapterUpdate();
		}
		//设置考试按钮显示状态
		function setupExamBtnStatus(){
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				pid : api.pageParam.planid,
				cid : api.pageParam.courseid
			}
			// console.log(url_freeCourseSchedule+'\n'+JSON.stringify(param));
			cfnetppPOST(url_freeCourseSchedule, param, false, function(data, status){
				// alert(JSON.stringify(data));
				if (status == 'success') {
					if (data.code == 200) {
						var studiedNum = parseInt(numStrWithStr(data.data[0].videosum));
						var allNum = parseInt(numStrWithStr(data.data[0].videosums));
						if (studiedNum == allNum) {//如果学完则执行是否显示考试按钮
							setupExamBtn();
						}
					}
				}
			});
		}
		function numStrWithStr(str){
			if (str == '' || str == null || str == undefined) {
				return '0';
			}
			return str;
		}
		function sendBuriedNotifi(busionessid,pagetype,pagetypeid,vid){
		    var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
				cid : api.pageParam.courseid,
				pid : api.pageParam.planid
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl :  window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			if(vid!=""){
	     		userinfo["vid"]=vid;
	     		data["accesspagetitle"]="自由课程视频章节";
	   		}
			
			SendBehaviorTrajectoriesNotifi_Study(data);
		}
		
		
		function setupChapterChart(chapterid){
			var jid = $api.getStorage('cfnetppjxid');
			if (api.pageParam.isxueba == 1) {
				jid = '419';
			}
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : jid,
				cid : api.pageParam.courseid,
				pid : api.pageParam.planid,
				chapterid : chapterid
			};
			// console.log(url_getSubChapterStudiedDetail+JSON.stringify(param));
			cfnetppPOST(url_getSubChapterStudiedDetail, param, true, function(data, status){
				if (status == 'success') {
					if (data.code == 200) {
						var chartData = data.data;
						setupChart(chapterid, chartData);
					}else{
						setupChart(chapterid, null);
					}
				}else{
					setupChart(chapterid, null);
				}
			});
		}
		function setupChart(chapterid, data){
			// console.log(JSON.stringify(data));
			var chartid = 'chart' + chapterid;
			if ($('#'+chartid).length == 0) {
				return;
			}
			var studiedNum;
			var unStudyNum;
			var percentage;
			var myChart = echarts.init(document.getElementById(chartid));
			if (data == null) {
				studiedNum = 0;
				unStudyNum = 1;
				percentage = '0%';//百分比
			}else{
				studiedNum = parseInt(data.studiednum.toString());
				var allNum = parseInt(data.allchapternum.toString());
				if (allNum < studiedNum) {
					allNum = studiedNum;
				}
				if (allNum == 0) {
					allNum = 1;
					studiedNum = 1;
				}
				unStudyNum = allNum - studiedNum;
				percentageNum = (studiedNum / allNum) * 100;
				percentage = percentageNum.toFixed(0) + '%'; 
			}
			myChart.setOption({
				title: {
			        text: percentage,
			        x: 'center',
			        y: 'center',
			        textStyle:{
				        //文字颜色
				        color:'#666',
				        //字体风格,'normal','italic','oblique'
				        fontStyle:'normal',
				        //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
				        fontWeight:'bold',
				        //字体系列
				        fontFamily:'sans-serif',
				        //字体大小
				　　　　 fontSize:14
				    }
			    },
				series: [
				    {
				        type:'pie',
				        radius: ['70%', '100%'],
				        avoidLabelOverlap: true,
				        label: {
				            normal: {
				                show: true,
				                position: 'center'
				            },
				            emphasis: {
				                show: true
				            }
				        },
				        labelLine: {
				            normal: {
				                show: true
				            }
				        },
				        data:[
				            {value:studiedNum},
				            {value:unStudyNum}
				        ],
				        color:['#18b4ed', '#d0d0d0']
				    }
				]
			});
		}
		/*没有考试次数通过考试  1  
		 * 没有考试次数没通过考试 2  
		 * 又考试次数通过考试3 
		 * 有考试次数没通过考试4  
		 * 5  是  通过 考试 无限次的 
		 * 6是没有通过考试的
		 */
		function setupExamBtn() {
			var examid = api.pageParam.examid;
			var params = {
				exam_id : api.pageParam.examid,
				user_id : $api.getStorage('cfnetppuid'),
				cid : api.pageParam.courseid,
				pid : api.pageParam.planid
			};
			cfnetppPOST(url_getCourseExamType, params, true, function(data, status) {
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					if (data.code == 200) {
					var is_score = data.data[0].is_score;
					score_id = data.data[0].score_id;
					score = data.data[0].score;
					
					
						if (examid != undefined && examid != null && examid != '' && examid != "0"&& examid != 0) {
							if (is_score == 4 || is_score == 6) {//开始考试
								$("#study_btn").text("开始考试");
								open_type = 0;
								$(".blank-div").show();
								$(".footer-view").show();
							} else if (is_score == 1 || is_score == 2 || is_score == 3 || is_score == 5) {//查看考试结果
								$("#study_btn").text("查看考试结果");
								open_type = 1;
								$(".blank-div").show();
								$(".footer-view").show();
							}else{
								$(".blank-div").hide();
								$(".footer-view").hide();
							}
						} else {
							$(".blank-div").hide();
							$(".footer-view").hide();
						}
					} else if (data.code == 108) {
					   if(examid != undefined && examid != null && examid != '' && examid != "0"&& examid != 0){
					      $(".blank-div").show();
						  $(".footer-view").show();
						  $("#study_btn").text("开始考试");
						  open_type = 0;
					   }else{
					      $(".blank-div").hide();
						  $(".footer-view").hide();
					      open_type = 1;
					   }
					} else {
						$(".blank-div").hide();
						$(".footer-view").hide();
					}
				} else {
					$(".blank-div").hide();
					$(".footer-view").hide();
				}
			});
		}

		function onExamClick() {
		sendBuriedNotifi(1, '章节列表', '028','');
			api.openWin({useWKWebView:true,
				name : 'Student_CourseTestExam',
				url : 'Student_CourseTestExam.html',
				pageParam : {
					appkey : 148745497845,
					match_type : 3,
					exam_id : api.pageParam.examid,
					plan_id : api.pageParam.planid,
					course_id : api.pageParam.courseid,
					score_id : score_id,
					open_type : open_type,
					score : score,
				    type :1,//自由课程
				    sourceurl : window.location.pathname,
					sourcetitle : document.title,
					openType : api.pageParam.openType
				}
			});
			
		}

		//下拉刷新
		function setRefreshHeader() {
			api.setRefreshHeaderInfo({
				visible : true,
				bgColor : '#ccc',
				textColor : '#fff',
				textDown : '下拉刷新...',
				textUp : '松开刷新...',
				showTime : true
			}, function(ret, err) {
				loadChapterData();
			});
		}

		function ReceNotifi() {
			api.addEventListener({
				name : 'RefreshCourseTestNotifi'
			}, function(ret, err) {
				setupExamBtn();
			});
			api.addEventListener({
				name : 'chapterUpdateNotifi'
			}, function(ret, err) {
				// loadChapterData();
			});
			api.addEventListener({
			    name: 'freeCourseRecordNotifi'
			}, function(ret, err) {
			    var chapterid = ret.value.vid;
				if(Date.parse(new Date())-freeCourseStart<60*1000){
					//学习时长不够一分钟
					return;
				}
			    $('#chapterStatus'+chapterid).show();
			    var baseChapterid = $('#'+chapterid).parents('.chapter-bg-content').attr('chapterid');
				if (baseChapterid == undefined) {//如果是最外层父章节则返回undefined
					baseChapterid = chapterid;
				}
				setTimeout(function(){
					// setupCharts();
					setupChapterChart(baseChapterid);
					api.sendEvent({
					    name: 'refreshPeopleListSelfDta',
					    extra: {
					        pid: api.pageParam.planid,
					        cid: api.pageParam.courseid
					    }
					});
				}, 1000);
			});
			api.addEventListener({
			    name: 'baiduWebVideoBackNotifi'
			}, function(ret, err) {
				var isfile = ret.value.isfile;
				var vid = ret.value.vid;
	          	if(isfile == 0){//视频章节
	              	sendBuriedNotifi(1, '自由课程视频章节', '031',vid);
	            }else{//文件章节
	              	sendBuriedNotifi(1, '自由课程文件章节', '029',vid);
	            }
	            //退出视频时发送结束学习通知
	            api.sendEvent({
	                name: 'freeCourseRecordNotifi',
	                extra: {
                		uid : $api.getStorage('cfnetppuid'),
						jid : $api.getStorage('cfnetppjxid'),
						cid : api.pageParam.courseid,
						vid : vid,
						pid : api.pageParam.planid
	                }
	            });
			});
			//百度文档模块返回回调通知
			api.addEventListener({
			    name: 'StudyWebBaiDuDocBackNotifi'
			}, function(ret, err) {
			    var vid = ret.value.vid;
			    api.sendEvent({
	                name: 'freeCourseRecordNotifi',
	                extra: {
                		uid : $api.getStorage('cfnetppuid'),
						jid : $api.getStorage('cfnetppjxid'),
						cid : api.pageParam.courseid,
						vid : vid,
						pid : api.pageParam.planid
	                }
	            });
			});
			//图片退出时回调
			api.addEventListener({
			    name: 'imageBackNotifi'
			}, function(ret, err) {
				if (ret.value.extendData == undefined || ret.value.extendData == null) {
					return;
				}
			    var vid = ret.value.extendData.vid;
			    api.sendEvent({
	                name: 'freeCourseRecordNotifi',
	                extra: {
                		uid : $api.getStorage('cfnetppuid'),
						jid : $api.getStorage('cfnetppjxid'),
						cid : api.pageParam.courseid,
						vid : vid,
						pid : api.pageParam.planid
	                }
	            });
			});
			//页面即将显示
			api.addEventListener({
			    name: 'viewappear'
			}, function(ret, err) {
				//页面即将显示时刷新考试按钮状态
				setupExamBtnStatus();
				//结束学习时间记录
			    api.sendEvent({
			        name: 'endFreeChapterStudyTimeNotifi',
			        extra: {
			        	uid : $api.getStorage('cfnetppuid'),
						jid : $api.getStorage('cfnetppjxid'),
			        	vid : currentVid,
			        	cid : api.pageParam.courseid,
						pid : api.pageParam.planid
			        }
			    });
			});
		}
		function saveTimeStamp(){
	        var timestamp = new Date().getTime();
	        var timeStampStr = timestamp.toString();
	        $api.setStorage('chapterLastTimeStamp', timeStampStr);
	        $api.setStorage('chapterLastCourseId', api.pageParam.courseid);
	        $api.setStorage('chapterLastPlanId', api.pageParam.planid);
	    }
		function loadChapterData() {
			firstLoad = true;
			var params = {
				cid : api.pageParam.courseid
			};
			// console.log(url_freeChapterUrl+'\n'+JSON.stringify(params));
			cfnetppPOST(url_freeChapterUrl, params, true, function(data, status) {
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					if (data.status == true) {
						//存储最后刷新的一次时间戳
						saveTimeStamp();
						var chapterlist = data.data;
						if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
							chapterArr = chapterlist;
							setupChapterList();
							//设置章节列表
							$('.noDataDiv').hide();
							$('.noInternetDiv').hide();
						} else {
							$('.noDataDiv').show();
							$('.noInternetDiv').hide();
						}
					} else {
						api.toast({
							msg : '自由课程章节列表加载失败'
						});
						$('.noDataDiv').show();
						$('.noInternetDiv').hide();
					}
				} else {
					api.toast({
						msg : '自由课程章节列表加载失败'
					});
					$('.noDataDiv').hide();
					$('.noInternetDiv').show();
				}
			});
		}
		//设置第二子章节
		function setupChildChapterList(prefix, chapterid, type) {
			var jid = $api.getStorage('cfnetppjxid');
			if (api.pageParam.isxueba == 1) {
				jid = '419';
			}
			var params = {
				cid : api.pageParam.courseid,
				pid : chapterid,
				uid : $api.getStorage('cfnetppuid'),
				jhid : api.pageParam.planid,
				jid : jid
			};
			// console.log(JSON.stringify(params)+'\n'+url_subChapterUrl);
			cfnetppPOST(url_subChapterUrl, params, true, function(data, status) {
				if (status == 'success') {
					if (data.status == true) {
						var chapterlist = data.data;
						if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
							setupSubChapterList(prefix, chapterlist);
						}
					} else {
					}
				} else {
				}
			});
		}
		//设置第二子章节
		function setupChildChapterList_old(prefix, chapterid, type) {
			$('.div_after').hide();
			if ($(type).hasClass("class_none") || prefix == 1) {
				uploadChapterStudyRecord(chapterid);
				//上传章的学习记录
				if (prefix == 1) {
					if (firstLoad == true) {
						firstLoad = false;
					} else {
						$(type).next('.div_after').show();
						return;
					}
					$('#' + chapterid).removeClass("class_none");
				}
				var params = {
					cid : api.pageParam.courseid,
					pid : chapterid,
					uid : $api.getStorage('cfnetppuid'),
					jhid : api.pageParam.planid
				};
				cfnetppPOST(url_subChapterUrl, params, true, function(data, status) {
					if (status == 'success') {
						if (data.status == true) {
							var chapterlist = data.data;
							if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
								setupSubChapterList(prefix, chapterlist);
							}
						} else {
						}
					} else {
					}
				});
				$(type).removeClass("class_none");
			}
			$(type).next('.div_after').show();
		}

		//设置第三子章节列表
		function childsetupChildChapterList(prefix, chapterid) {
			var jid = $api.getStorage('cfnetppjxid');
			if (api.pageParam.isxueba == 1) {
				jid = '419';
			}
			var params = {
				cid : api.pageParam.courseid,
				pid : chapterid,
				uid : $api.getStorage('cfnetppuid'),
				jhid : api.pageParam.planid,
				jid : jid
			};
			// console.log(url_subChapterUrl+'\n'+JSON.stringify(params));
			cfnetppPOST(url_subChapterUrl, params, true, function(data, status) {
				if (status == 'success') {
					if (data.status == true) {
						var chapterlist = data.data;
						if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
							setchildupSubChapterList(prefix, chapterlist);
						}
					} else {
					}
				} else {
				}
			});
		}
		function setupCharts(){
			for (var i = 0; i < chapterArr.length; i++) {
				var chapterData = chapterArr[i];
				setupChapterChart(chapterData.id);
			}
		}
		//设置章节列表
		function setupChapterList() {
			$('#free_chapter_content').html('');
			for (var i = 0; i < chapterArr.length; i++) {
				var chapterData = chapterArr[i];
				var chapterHtmlStr = sectionHtmlWithData(i + 1, chapterData);
				$('#free_chapter_content').append(chapterHtmlStr);
				setupChapterChart(chapterData.id);//设置图表
				if (i == 0) {
					// $('#section_tap'+chapterData.id).addClass('mui-active');
					setupSectionCellClick($('#section_tap'+chapterData.id));
					setupChildChapterList(i + 1, chapterData.id);
				}
				// uploadChapterStudyRecord(chapterData.id);
				//拼接章html串
				// if (parseInt(chapterData.child) > 0) {
					// setupChildChapterList(i + 1, chapterData.id);
				// }
			}
			setupSectionTapClick();
		}
		function setupSectionCellClick(sectionCell){
			var contentDiv = sectionCell.next('.section-content');
			var img = sectionCell.children('.section-slider-handle').children('.section-right-img');
			if (contentDiv.hasClass('isShow')) {
				contentDiv.hide();
				contentDiv.addClass('isHide');
				contentDiv.removeClass('isShow');
				img.attr('src', '../../image/icon_bewrite_down.png');
			}else{
				contentDiv.show();
				contentDiv.addClass('isShow');
				contentDiv.removeClass('isHide');
				img.attr('src', '../../image/icon_bewrite_up.png');
			}
		}
		//设置第二子章节列表
		function setupSubChapterList(prefix, chapterlist) {
			var subChapterHtmlStr = '';
			for (var i = 0; i < chapterlist.length; i++) {
				var chapterData = chapterlist[i];
				subChapterObjc[chapterData.id] = chapterData;
				subChapterHtmlStr += cellHtmlWithData(prefix, i + 1, chapterData);
				// if (parseInt(chapterData.child) > 0) {
				// 	childsetupChildChapterList(prefix + '.' + (i + 1), chapterData.id);
				// }
			}
			$('#aft_chapterid' + chapterData.pid).after(subChapterHtmlStr);
			// $('#' + chapterData.pid).after('<div class="div_after">' + subChapterHtmlStr + '</div>');
			setSubChapterClick();
			setupBewriteClick();
		}

		//设置第三子章节列表
		function setchildupSubChapterList(prefix, chapterlist) {
			var subChapterHtmlStr = '';
			for (var i = 0; i < chapterlist.length; i++) {
				var chapterData = chapterlist[i];
				subChapterObjc[chapterData.id] = chapterData;
				subChapterHtmlStr += cellHtmlWithData(prefix, i + 1, chapterData);
				// if (parseInt(chapterData.child) > 0) {
				// 	childsetupChildChapterList(prefix + '.' + (i + 1), chapterData.id);
				// }
			}
			$('#aft_chapterid' + chapterData.pid).after(subChapterHtmlStr);
			setSubChapterClick();
			setupBewriteClick();
		}
		function setupSectionTapClick(){
			$('.section-cell').unbind('click');
			$('.section-cell').click(function(){
				setupSectionCellClick($(this));
				var chapterid = $(this).attr('chapterid');
				// uploadChapterStudyRecord(chapterid);//屏蔽part学习进度
				// console.log($('#aft_chapterid'+chapterid).next().length);
				if($('#aft_chapterid'+chapterid).next().length == 0){//如果下一个元素不存在，加载该章节
					var index = parseInt($(this).attr('index'));
					setupChildChapterList(index + 1, chapterid);
				}
			});
		}
		function sectionHtmlWithData(index, data) {
			var isclose = data.isclose;
			if (isclose == '1') {
				return "";
			}
			var trainsObj = new GB2312UTF8();
			return '<div chapterid="'+data.id+'" index="'+index+'" class="mui-content chapter-bg-content">'+
					'<div class="mui-card">'+
						'<ul class="mui-table-view">'+
							'<li chapterid="'+data.id+'" id="section_tap'+data.id+'" class="mui-table-view-cell section-cell">'+
								'<div class="section-slider-handle">'+
									'<div class="section-right-div">'+
      									'<p class="section-title base_dark_grey base_content_font">'+
											trainsObj.Utf8ToGb2312(data.cdetailtitle)+
										'</p>'+
      								'</div>'+
      								'<div id="chart'+data.id+'" class="section-chart"></div>'+
      								'<div class="section-chart-mask"></div>'+
      								'<img class="section-right-img" src="../../image/icon_bewrite_down.png">'+
								'</div>'+
							'</li>'+
							'<div class="section-content">'+
								'<div class="zhan-wei-div" id="aft_chapterid' + data.id + '">'+
							'</div>'+
						'</ul>'+
					'</div>'+
				'</div>';
		}
		function imagePathWithUrlPath(fileName){
			var fileSuffix = fileSuffixWithPath(fileName);
			if (fileSuffix == '.doc' || fileSuffix == '.docx') {
				return '../../image/icon_chapter_doc.png';
			}else if(fileSuffix == '.pdf'){
				return '../../image/icon_chapter_pdf.png';
			}else if(fileSuffix == '.xls' || fileSuffix == '.xlsx'){
				return '../../image/icon_chapter_excel.png';
			}else if(fileSuffix == '.ppt' || fileSuffix == '.pptx'){
				return '../../image/icon_chapter_ppt.png';
			}else if(fileSuffix == '.png' || fileSuffix == '.jpg' || fileSuffix == '.jpeg' || fileSuffix == '.bmp' || fileSuffix == '.gif'){
				return '../../image/icon_chapter_img.png';
			}else if(fileSuffix == '.mp4' || fileSuffix == '.avi' || fileSuffix == '.rmvb' || fileSuffix == '.3gp' || fileSuffix == '.flv' || fileSuffix == '.wmv'){
				return '../../image/09.png';
			}else{
				return '../../image/011.png';
			}
		}
		function fileSuffixWithPath(path){
			var result =/\.[^\.]+/.exec(path);
			return result;
		}
		function cellHtmlWithData(prefix, index, data) {
			var isclose = data.isclose;
			if (isclose == '1') {
				return "";
			}
			var content_type = data.content_type;
			var imgSrc = '';
			var folderRightImage = '';
			var folderContentDiv = '';
			var subChapterToggleDiv = '';
			if (parseInt(data.child) > 0) {//如果有子章节
				subChapterToggleDiv = '<div chapterid="'+data.id+'" prefix="'+prefix+'" index="'+index+'" class="drop-down-tap-div sub-chapter-hide"></div>';
				folderRightImage = '<div class="weui-cell__ft cell-right-down">'+
										'<img id="folder_right_img'+data.id+'" class="cell-right-img" src="../../image/icon_bewrite_down.png">'+
									'</div>';
			}
			if (content_type == 'richtext') {//富文本
				if (data.rid == '') {//富文本
					imgSrc = '../../image/08.png';
				} else {//视频
					imgSrc = '../../image/09.png';
				}
			} else if (content_type == 'survey') {//调查
				imgSrc = '../../image/03.png';
			} else if (content_type == 'tests') {//测验
				imgSrc = '../../image/01.png';
			} else if (content_type == 'discuss') {//讨论
				imgSrc = '../../image/02.png';
			} else if (content_type == 'works') {//作业
				imgSrc = '../../image/04.png';
			} else if (content_type == 'folder') {//文件夹
				imgSrc = '../../image/010.png';
				folderRightImage = '<div class="weui-cell__ft cell-right-down">'+
										'<img id="folder_right_img'+data.id+'" class="cell-right-img" src="../../image/icon_bewrite_down.png">'+
									'</div>';
				folderContentDiv = '<div id="folder_file_div'+data.id+'" class="folder-content"></div>';
			} else if (content_type == 'files') {//文件
				// imgSrc = '../../image/011.png';
				var rid = data.rid;
				var ridArr = rid.split('||');
				var fileName = ridArr[0];
				imgSrc = imagePathWithUrlPath(fileName);
			} else if (content_type == 'sitenow') {//现场实操
				imgSrc = '../../image/05.png';
			} else if (content_type == 'hdresource') {//互动资源
				imgSrc = '../../image/06.png';
			} else if (content_type == 'sysdeal') {//系统处理
				imgSrc = '../../image/icon_scorm.png';
			} else if (content_type == 'flash') {//flash动画
				imgSrc = '../../image/icon_flash.png';
			} else if (content_type == 'tag') {
				imgSrc = '../../image/07.png';
			} else {
				imgSrc = '../../image/icon_scorm.png';
			}
			var index_i = prefix + '.' + index;
			var preArr = index_i.split(".");
			var marginLeftClass = '';
			// if (preArr.length == 0 || preArr.length == 1) {
			// } else if (preArr.length == 2) {
			// 	// marginLeftClass = " img_margin_left_1";
			// } else if (preArr.length == 3) {
			// 	// marginLeftClass = " img_margin_left_2";
			// 	marginLeftClass = " img_margin_left_1";
			// } else if (preArr.length == 4) {
			// 	// marginLeftClass = " img_margin_left_3";
			// 	marginLeftClass = " img_margin_left_1";
			// } else {
			// 	// marginLeftClass = " img_margin_left_4";
			// 	marginLeftClass = " img_margin_left_1";
			// }
			var chapterStatus = '<div id="chapterStatus'+data.id+'" class="weui-cell__ft" hidden="hidden">'+
									'<img class="cell-right-img" src="../../image/icon_studied.png">'+
								'</div>';
			if (data.status == 1) {
				chapterStatus = '<div id="chapterStatus'+data.id+'" class="weui-cell__ft">'+
									'<img class="cell-right-img" src="../../image/icon_studied.png">'+
								'</div>';
			}
			//描述
			var bwriteHtml = bewriteHtmlWithData(data);

			var afterHtml = '<div id="subChapterContent'+data.id+'" class="sub-chapter-content-hide sub-chapter-content-fdiv">'+
								'<div class="sub-chapter-content-line"></div>'+
								'<div class="sub-chapter-content">'+
									'<div id="aft_chapterid'+data.id+'" hidden="hidden"></div>'+
								'</div>'+
							'</div>';
			return '<div id="' + data.id + '" class="weui_cell sub_chapter_cell base_content_color_font">'+
				'<div class="weui_cell_hd'+marginLeftClass+'">'+
					'<img src="' + imgSrc + '" alt="" class="chapter_cell_left_icon">'+
				'</div>'+
				'<div class="weui_cell_bd weui_cell_primary">'+
					'<p class="base_dark_grey base_tag_font">'+
						'<span class="chapter_title">' + data.cdetailtitle + '</span>'+
					'</p>'+
				'</div>'+
				chapterStatus+
				folderRightImage+
				subChapterToggleDiv+
			'</div>'+
			bwriteHtml+
			folderContentDiv+
			afterHtml;
		}

		function setSubChapterClick() {
			$('.sub_chapter_cell').unbind('click');
			$('.sub_chapter_cell').click(function() {
				$('.sub_chapter_cell').removeClass('base_style_text_color');
				$(this).addClass('base_style_text_color');
				var chapterid = $(this).attr('id');
				currentVid = chapterid;//记录当前点击vid
				var subChapterData = subChapterObjc[chapterid];
				var content_type = subChapterData.content_type;
				// if (content_type != 'survey' && content_type != 'tests' && content_type != 'discuss' && content_type != 'works' && content_type != 'sitenow') {
				// 	uploadChapterStudyRecord(chapterid);//记录一次学习
				// }
				if (content_type != 'part' && content_type != 'tag' && content_type != 'sysdeal' && content_type != 'flash' && content_type != 'folder') {
					uploadChapterStudyRecord(chapterid);//记录一次学习
				}
				pushToNextWindow(subChapterData);
			});
			$('.bewrite-cell').unbind('click');
			$('.bewrite-cell').click(function(){
				var chapterid = $(this).attr('chapterid');
				currentVid = chapterid;//记录当前点击vid
				$('.sub_chapter_cell').removeClass('base_style_text_color');
				$('#'+chapterid).addClass('base_style_text_color');
				var subChapterData = subChapterObjc[chapterid];
				var content_type = subChapterData.content_type;
				if (content_type != 'part' && content_type != 'tag' && content_type != 'sysdeal' && content_type != 'flash' && content_type != 'folder') {
					uploadChapterStudyRecord(chapterid);//记录一次学习
				}
				pushToNextWindow(subChapterData);
			});
			$('.drop-down-tap-div').unbind('click');
			$('.drop-down-tap-div').click(function(event){
				var chapterid = $(this).attr('chapterid');
				currentVid = chapterid;//记录当前点击vid
				if ($('#aft_chapterid'+chapterid).next().length == 0) {
					var prefix = $(this).attr('prefix');
					var index = $(this).attr('index');
					childsetupChildChapterList(prefix + '.' + index, chapterid);
				}
				if ($(this).hasClass('sub-chapter-hide')) {
					$(this).removeClass('sub-chapter-hide');
					$('#subChapterContent'+chapterid).removeClass('sub-chapter-content-hide');
					$('#folder_right_img'+chapterid).attr('src', '../../image/icon_bewrite_up.png');
				}else{
					$(this).addClass('sub-chapter-hide');
					$('#subChapterContent'+chapterid).addClass('sub-chapter-content-hide');
					$('#folder_right_img'+chapterid).attr('src', '../../image/icon_bewrite_down.png');
				}
				event.stopPropagation();
			});
		}
		//上传章节学习记录
		function uploadChapterStudyRecord(vid) {
			// api.sendEvent({
			// 	name : 'freeCourseRecordNotifi',
			// 	extra : {
			// 		uid : $api.getStorage('cfnetppuid'),
			// 		jid : $api.getStorage('cfnetppjxid'),
			// 		cid : api.pageParam.courseid,
			// 		vid : vid,
			// 		pid : api.pageParam.planid
			// 	}
			// });
			//记录学习状态
			api.sendEvent({
			    name: 'freeStartRecordNotifi',
			    extra: {
			        uid : $api.getStorage('cfnetppuid'),
					jid : $api.getStorage('cfnetppjxid'),
					cid : api.pageParam.courseid,
					vid : vid,
					pid : api.pageParam.planid
			    }
			});
		}

		//根据类型跳转页面
		function pushToNextWindow(data) {
			//sourceUrl
			// alert('pushToNextWindow:'+JSON.stringify(data));
			sendBuriedNotifi(1, '自由课程章节列表', '028','');
			var pid = api.pageParam.planid;
			var cType = data.content_type;
			var winName = '';
			var isclose = data.isclose;
			var bewrite = data.bewrite;
			var is_encr = data.is_encr;
			var baidu_cloud_id_url = data.baidu_cloud_id_url;
			var baidu_cloud_id = data.baidu_cloud_id;
			var sourceUrl = data.sourceUrl;
			data["cid"] = api.pageParam.courseid;
			freeCourseStart=freeCourseStart=Date.parse(new Date());
			//开始计时
			api.sendEvent({
				name: 'freeCourseStart',
			});
			if (isclose == '1') {
				api.toast({
					msg : '该课时尚未发布，暂不能学习',
					duration : 3000,
					location : 'bottom'
				});
				return;
			}
			var pageParam = new Object();
			if (cType == 'richtext') {//富文本
			   	UploadAddChapterInformation(pid,data.id);
				if (data.rid == '') {//富文本
					winName = 'studyCourseRichtextNew';
				} else {//视频
					var videoUrl = data.rid;
					if (sourceUrl != null && sourceUrl != '' && sourceUrl.indexOf("http://") >= 0) {
						videoUrl = sourceUrl;
					}
					// if (videoUrl.indexOf("http://") < 0 && sourceUrl != '') {
					// 	videoUrl = sourceUrl;
					// }
					var connectionType = api.connectionType;
					if (connectionType != 'wifi' && connectionType != 'none') {
						api.confirm({
							title : '提示',
							msg : '您当前处于移动数据网络下，是否继续播放',
							buttons : ['确定', '取消']
						}, function(ret, err) {
							var index = ret.buttonIndex;
							if (index == 1) {//确定
								pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, videoUrl, data.cdetailtitle, data.id,0);
							}
						});
					} else {
						pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, videoUrl, data.cdetailtitle, data.id,0);
					}
					return;
				}
				pageParam = {
					vid : data.id,
					pid : pid,
					cid : data.cid,
					cdetailtitle : data.cdetailtitle,
					richtextType : 1,
					other : data.other,
					bewrite : data.bewrite,
					is_dis_bewrite : data.is_dis_bewrite,
					content_type : cType,
					rid : data.rid,
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				};
			} else if (cType == 'survey') {//调查
				$api.setStorage('Research_title', data.cdetailtitle);
				$api.setStorage('Research_sourceurl', window.location.pathname);
				$api.setStorage('Research_sourcetitle', document.title);
				
				winName = 'New_Student_Study_ResearchExam';
				pageParam = {
					id : data.id,
					pid : pid,
					cid : data.cid,
					cdetailtitle : data.cdetailtitle,
					rid : data.rid,
					bewrite : data.bewrite,
					is_dis_bewrite : data.is_dis_bewrite,
					content_type : cType,
					isfreecorse:'1'
//					sourceurl : window.location.pathname,
//					sourcetitle : document.title
				};
			} else if (cType == 'tests') {//测验
				$api.setStorage('Test_title', data.cdetailtitle);
				$api.setStorage('Research_sourceurl', window.location.pathname);
				$api.setStorage('Research_sourcetitle', document.title);
				winName = 'New_student_study_freecourse_TestExam';
				pageParam = {
					id : data.id,
					pid : pid,
					cid : data.cid,
					cdetailtitle : data.cdetailtitle,
					rid : data.rid,
					bewrite : data.bewrite,
					isanswer : data.isanswer,
					is_cy : data.is_cy,
					is_cypass : data.is_cypass,
					examnum : data.examnum,
					is_dis_bewrite : data.is_dis_bewrite,
					isteacher : 1,
					type : 1,
					content_type : cType,
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				};
			} else if (cType == 'discuss') {//讨论
				winName = 'New_Student_FreeCourse_DiscussChapterWindow';
				pageParam = {
					chapterid : data.id,
					pid : pid,
					cid : data.cid,
					cdetailtitle : data.cdetailtitle,
					bewrite : data.bewrite,
					is_dis_bewrite : data.is_dis_bewrite,
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				};
			} else if (cType == 'works') {//作业
				winName = 'new_student_study_freecourse_homeworks';
				pageParam = {
					pid : pid,
					chapterid : data.id,
					cdetailtitle : data.cdetailtitle,
					bewrite : data.bewrite,
					is_dis_bewrite : data.is_dis_bewrite,
					cid : api.pageParam.courseid,
					sourceurl : window.location.pathname,
					sourcetitle : document.title
				};
			} else if (cType == 'folder') {//文件夹
			   	UploadAddChapterInformation(pid,data.id);
				setupFolderFCellClick(data.id);
				sendBuriedNotifi(0, '自由课程文件夹章节', '030', data.id);
				setTimeout(function() {
					sendBuriedNotifi(1, '自由课程文件夹章节', '030', data.id);
				}, 1000);
				return;
			} else if (cType == 'files') {//文件
			    UploadAddChapterInformation(pid,data.id);
				setupFilesChapter(pid,data);
				sendBuriedNotifi(0, '自由课程文件夹章节', '029', data.id);
				setTimeout(function() {
					sendBuriedNotifi(1, '自由课程文件夹章节', '029', data.id);
				}, 1000);
				return;
			} else if (cType == 'sitenow') {//现场实操
//			alert(api.pageParam.ifteacherstudy)
				winName = 'new_Mark_sheet';
				pageParam = data;
				pageParam["ifteacherstudy"] = api.pageParam.ifteacherstudy;
				pageParam["pid"] = pid;
				pageParam["sourceurl"] = window.location.pathname;
				pageParam["sourcetitle"] = document.title;
				$api.setStorage('sc_cid', data.cid);
			    $api.setStorage('sc_pid', pid);
			    $api.setStorage('sc_vid',data.id);
			} else if (cType == 'hdresource') {//互动资源
			    UploadAddChapterInformation(pid,data.id);
				if (api.connectionType == 'none') {
					api.toast({
						msg : '暂无网络，无法访问该内容'
					});
					return;
				}
				winName = 'student_study_freecourse_interactiveNew';
				pageParam = data;
				pageParam["planid"] = pid;
				pageParam["type"] = 1;
				pageParam["sourceurl"] = window.location.pathname;
				pageParam["sourcetitle"] = document.title;
			} else if (cType == 'tag') {//标签
				return;
			} else {
				api.toast({
					msg : '手机不支持该类型，请在电脑上查看'
				});
				return;
			}
			if (winName == 'New_student_study_freecourse_TestExam' || winName == 'New_Student_Study_ResearchExam') {
				pageParam["openType"] = api.pageParam.openType;
				api.openWin({useWKWebView:true,
					name : winName,
					url : winName + '.html',
					pageParam : pageParam,
					slidBackEnabled : false,
					softInputMode : 'pan'
				});
			} else {
				api.openWin({useWKWebView:true,
					name : winName,
					url : winName + '.html',
					pageParam : pageParam,
					slidBackEnabled : false
				});
			}

		}

		function setupFilesChapter(pid,data){
			// alert('setupFilesChapter:'+JSON.stringify(data));
			sendBuriedNotifi(1, '自由课程章节列表', '028','');
			var is_encr = data.is_encr;
			var baidu_cloud_id_url = data.baidu_cloud_id_url;
			var baidu_cloud_id = data.baidu_cloud_id;
			var rid = data.rid;
			var ridArr = rid.split('||');
			var title = ridArr[0];
			var doc = ridArr[1];
			var sourceUrl = data.sourceUrl;
			if (sourceUrl != null && sourceUrl != ''){
				doc = sourceUrl;
			}
			var arr = new Array('jpg', 'png', 'jpeg');
			var gifArr = new Array('gif', 'bmp');
			var arr1 = new Array('swf', 'mp4', 'flv', '3gp', 'mov', 'rmvb', 'avi', 'wmv', 'flv%22', 'mp4%22', 'mov%22', '3gp%22', 'rmvb%22', 'avi%22', 'wmv%22');
			var ext = doc.replace(/.+\./, "");
			var vid = data.id;
			var userinfo = {
				vid : vid,
				pid : pid,
			    cid : data.cid
			}
			var extendData = {
				vid : vid
			};
			if (gifArr.toString().indexOf(ext) > -1){
				openGif(doc, extendData);
			}else if (arr.toString().indexOf(ext) > -1) {
				openImage(doc, extendData);
			} else {
				if (arr1.toString().indexOf(ext) > -1) {
					var connectionType = api.connectionType;
		            if (connectionType != 'wifi' && connectionType != 'none') {
		            	api.confirm({
		                    title: '提示',
		                    msg: '您当前处于移动数据网络下，是否继续播放',
		                    buttons: ['确定', '取消']
		                }, function(ret, err) {
		                    var index = ret.buttonIndex;
		                    if (index == 1) {//确定
		                        // openVideoWin(doc, title);
		                        pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, doc, title, vid,1);
		                    }
		                });
		            }else{
		            	// openVideoWin(doc, title);
		            	pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, doc, title, vid,1);
		            }
				} else {
					if (api.connectionType == 'none') {
						api.toast({
							msg : '暂无网络，无法访问该内容'
						});
						return;
					}
					if (is_encr == 1) {//加密
				        api.openWin({useWKWebView:true,
						    name: 'StudyWebBaiDuDoc_win',
						    url: 'StudyWebBaiDuDoc_win.html',
						    pageParam: {
						        docId: baidu_cloud_id,
						        title: title,
								vid: vid
						    }
						});
					}else{
						api.openWin({useWKWebView:true,
							name : 'Student_FreeCourseDoc',
							url : 'Student_FreeCourseDoc.html',
							pageParam : {
								title : title,
								doc : doc,
							    vid : vid,
					            pid : pid,
					            cid : data.cid,
					            isFile:1,
								sourceurl : window.location.pathname,
					            sourcetitle : document.title     
							}
						});
					}
					// if (doc != 'undefined' && doc != undefined && doc != null && doc != ''){
					// 	api.openWin({useWKWebView:true,
					// 		name : 'Student_FreeCourseDoc',
					// 		url : 'Student_FreeCourseDoc.html',
					// 		pageParam : {
					// 			title : title,
					// 			doc : doc,
					// 		    vid : data.id,
					//             pid : pid,
					//             cid : data.cid,
					//             isFile:1,
					// 			sourceurl : window.location.pathname,
					//             sourcetitle : document.title     
					// 		}
					// 	});
					// }else{
					// 	if (baidu_cloud_id != null && baidu_cloud_id != '') {//加密
					// 		var CFBaiDuDoc = api.require('CFBaiDuDoc');
					//         CFBaiDuDoc.startDocActivityForResult({
					//             docId:baidu_cloud_id,//文档ID
					//             title:title,//文档标题
					//             token:"TOKEN",//文档token，离线加载时不验证。
					//             host:"BCEDOC",//文档所属站点
					//             docType:"doc" //文档类型，可取值为ppt 和 doc
					//         },function(){
					//         });
					// 	}else{
					// 		api.toast({
					// 		    msg: '文件打开失败'
					// 		});
					// 	}
					// }
					
				}
			}	
		}
			
	function pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, path, title,vid,isfile){
		// console.log('is_encr:'+is_encr+'\n'+'baidu_cloud_id_url:'+baidu_cloud_id_url+'\n'+'path:'+path);
		if (api.connectionType == 'none') {
			api.toast({
			    msg: '暂无网络，无法访问该资源'
			});
		}
		if(path != null && path != '' && path.indexOf("http://") < 0 ){
			path = 'http://bos.cfnet.org.cn' + path;
		}
		if(isfile==0){//视频章节
		  	sendBuriedNotifi('0', '自由课程视频章节', '031',vid);
		}else{//文件章节
		  	sendBuriedNotifi(0, '自由课程文件章节', '029',vid);
		} 
		var videoPath = path;
 		if (is_encr == 2) {//转码
			videoPath = baidu_cloud_id_url;
			api.openWin({useWKWebView:true,
				name: 'BaiDuWebVideo',
	 		    url: 'BaiDuWebVideo.html',
	 		    pageParam: {
	 		    	title: title,
	 		        url: videoPath,
	 		        token: '',
	 		        vid: vid,
	 		        isfile: isfile
	 		    },
	 		    slidBackEnabled: false
	 		});
		}else{
			api.openWin({useWKWebView:true,
	 		    name: 'BaiDuWebVideo',
	 		    url: 'BaiDuWebVideo.html',
	 		    pageParam: {
	 		    	title: title,
	 		        url: videoPath,
	 		        token: '',
	 		        vid: vid,
	 		        isfile: isfile
	 		    },
	 		    slidBackEnabled: false
	 		});
		}
		// if (path != '') {
		// 	var CFBaiDuVideo = api.require('CFBaiDuVideo');
			
		//     CFBaiDuVideo.initVideo({
		//        title : title,
		//        path : videoPath,
		//        isShowFullScreenBtn : 1,
		//        isShowFullScreen : 1,
		//        token : ''
		//     },function(ret, err){
		//       	if(isfile==0){//视频章节
	 //              	sendBuriedNotifi(1, '自由课程视频章节', '031',vid);
	 //            }else{//文件章节
	 //              	sendBuriedNotifi(1, '自由课程文件章节', '029',vid);
	 //            }
		//     });
		// }else{
		// 	if (is_encr == 1 || is_encr == 2) {//加密
		// 		videoPath = baidu_cloud_id_url;
		// 		getVideoToken(function(status, videoToken){
		// 			// alert('status:'+status+'\n'+'videoToken:'+videoToken);
					
		// 			var CFBaiDuVideo = api.require('CFBaiDuVideo');
		// 	        CFBaiDuVideo.initVideo({
		// 	           title : title,
		// 	           path : videoPath,
		// 	           isShowFullScreenBtn : 1,
		// 	           isShowFullScreen : 1,
		// 	           token : videoToken
		// 	        },function(ret, err){
		// 		       	if(isfile==0){//视频章节
		// 	              	sendBuriedNotifi(1, '自由课程视频章节', '031',vid);
		// 	            }else{//文件章节
		// 	              	sendBuriedNotifi(1, '自由课程文件章节', '029',vid);
		// 	            }
		// 	        });
		// 	    });
		// 	}else{
		// 		api.toast({
		// 		    msg: '视频播放失败！'
		// 		});
		// 	}
		// }
	}
	// 资源类上传操作
    function UploadAddChapterInformation(pid,id){
     	// 资源类上传操作
	    api.sendEvent({
		    name: 'AddChapterInformation',
		    extra: {
		        pid : pid,
		        cid : api.pageParam.courseid,
		        vid :id
		    }
        });
    }
	</script>
</html>